package cn.edu.scau.cmi.lijiongtao.client;

import cn.edu.scau.cmi.lijiongtao.adapter.AdapterOfClass;
import cn.edu.scau.cmi.lijiongtao.adapter.AdapterOfObject;
import cn.edu.scau.cmi.lijiongtao.adapter.Target;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class AdapterClient extends Application{
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		primaryStage.setTitle("实验四：适配器模式");
		primaryStage.setHeight(200);
		primaryStage.setWidth(317);
		
		Button bt1 = new Button("通过类适配器模式变压");
		Button bt2 = new Button("通过对象适配器模式变压");
		bt1.setMinWidth(150);
		bt2.setMinWidth(150);
		
		HBox hBox = new HBox();
		hBox.getChildren().addAll(bt1,bt2);
		
		Label lb = new Label();
		
		BorderPane bp = new BorderPane();
		bp.setBottom(hBox);
		bp.setCenter(lb);
		
		Scene s = new Scene(bp,480,600);
		primaryStage.setScene(s);
		primaryStage.show();
		
		bt1.setOnAction(e -> {
			Target target = new AdapterOfClass();
			lb.setText(target.doTarget());
		});
		
		bt2.setOnAction(e -> {
			Target target = new AdapterOfObject();
			lb.setText(target.doTarget());
		});
	}

}
